package com.taotao.common;

/**
 * 响应结果生成工具
 */
public class ResultGenerator {
    private static final String DEFAULT_SUCCESS_MESSAGE = "SUCCESS";
    private static final String DEFAULT_FAIL_MESSAGE = "FAIL";

    public static CommonResult genSuccessResult() {
    	return genSuccessResult(null);
    }

    public static CommonResult genSuccessResult(Object data) {
    	CommonResult result = new CommonResult();
    	result.setStatus(Constants.RESULT_CODE_SUCCESS);
        result.setMsg(DEFAULT_SUCCESS_MESSAGE);
        result.setData(data);
        return result;
    }

    public static CommonResult genFailResult(String message) {
    	CommonResult result = new CommonResult();
        result.setStatus(Constants.RESULT_CODE_SERVER_ERROR);
        if (message == null || message.length() < 1) {
            message = DEFAULT_FAIL_MESSAGE;
        }
        result.setMsg(message);
        return result;
    }

    public static CommonResult genLoginResult0(String message,int code,Object data){
    	CommonResult result = new CommonResult();
    	result.setStatus(code);
        result.setMsg(message);
        result.setData(data);
        return result;
    }
}
